// main.ts

import { createApp } from 'vue';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import App from './App.vue';
import router from './router';
import store from './store';
import './styles/global.css';

// 创建 Vue 实例
const app = createApp(App);

// 使用 Element Plus 插件
app.use(ElementPlus/*, { size: 'small', zIndex: 3000 }*/).use(store).use(router);

// 挂载 Vue 实例
app.mount('#app');

// 解决 Element Plus 的 el-table 频繁变化窗口的报错
const debounce = (fn, delay) => {
    let timer;
    return (...args) => {
        if (timer) {
            clearTimeout(timer);
        }
        timer = setTimeout(() => {
            fn(...args);
        }, delay);
    };
};

const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
    constructor(callback) {
        callback = debounce(callback, 200);
        super(callback);
    }
};

// document.addEventListener('keydown', (event) => {
//     if (event.key === 'Enter') {
//         event.preventDefault(); // 阻止enter默认行为
//     }
// });